package usaco.c2010.march.bronze;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

/*
 * p3598
 * USACO March 2010
 */

public class p3598 {

	static long F, M;
	static int np;
	static part[] ps;
	static Queue<Integer> q;

	public static void main(String[] args) throws Exception {
		
		Scanner scanner = new Scanner(System.in);
//		Scanner scanner = new Scanner(new File("boost.3.in"));
		F = scanner.nextLong();
		M = scanner.nextLong();
		np = scanner.nextInt();
		ps = new part[np];
		for (int i=0;i<np;++i) {
			int f, m;
			f = scanner.nextInt();
			m = scanner.nextInt();
			ps[i] = new part(f,m,i+1);
		}
		Arrays.sort(ps);
		q = new PriorityQueue<Integer>();
		for (int i=0;i<np;++i) {
			part p = ps[i];
			if (F * p.M < M * p.F) {
				F += p.F;
				M += p.M;
				q.add(p.n);
			}
		}
		if (q.isEmpty()) {
			System.out.println("NONE");
		}
		else {
			while (!q.isEmpty()) {
				System.out.println(q.poll());
			}
		}
	}

}
class part implements Comparable<part> {
	int F;
	int M;
	int n;
	part(int F, int M, int n) {
		this.F = F;
		this.M = M;
		this.n = n;
	}
	
	public int compareTo(part p) {
		int tmp = - F * p.M + M * p.F;
		if (tmp == 0) {
			return this.n - p.n;
		}
		else return tmp;
	}
}